package edu.ntu.im.p2ptrade.action;



import java.util.List;






public class AjaxResponse {

	

	private boolean success;

	private String errorMessage;

	private Object result;

	private ErrorCode errorCode;






	



	public String getErrorMessage() {

		return errorMessage;

	}



	public void setErrorMessage(String errorMessage) {

		this.errorMessage = errorMessage;

	}



	public Object getResult() {

		return result;

	}



	public void setResult(Object result) {

		this.result = result;

	}



	public boolean getSuccess() {

		return success;

	}



	public void setSuccess(boolean success) {

		this.success = success;

	}



	/**

	 * @return the errorCode

	 */

	public ErrorCode getErrorCode() {

		return errorCode;

	}



	/**

	 * @param errorCode

	 *            the errorCode to set

	 */

	public void setErrorCode(ErrorCode errorCode) {

		this.errorCode = errorCode;

	}



	public enum ErrorCode {

		OK(0), UncategorizedError(1), NeedLoginError(2), InvalidParameterError(

				3), NotFoundError(4), UnauthorizedError(5);

		private final int code;



		ErrorCode(int code) {

			this.code = code;

		}



		public int getCode() {

			return code;

		}

	}

	

	public static AjaxResponse createPagedListResponse(List list, int pageNum, int pageSize, int itemCount) {

		AjaxResponse resp = new AjaxResponse();

		resp.setResult(list);

		

		

		return resp;

	}

}

